/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv2.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.taobao.ibatiside.model.mapperv2.Discriminator;
import org.taobao.ibatiside.model.mapperv2.Mapperv2Package;
import org.taobao.ibatiside.model.mapperv2.SubMap;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Discriminator</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.DiscriminatorImpl#getSubMap <em>Sub Map</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.DiscriminatorImpl#getColumn <em>Column</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.DiscriminatorImpl#getColumnIndex <em>Column Index</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.DiscriminatorImpl#getJavaType <em>Java Type</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.DiscriminatorImpl#getJdbcType <em>Jdbc Type</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.DiscriminatorImpl#getNullValue <em>Null Value</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.DiscriminatorImpl#getTypeHandler <em>Type Handler</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DiscriminatorImpl extends EObjectImpl implements Discriminator {
	/**
	 * The cached value of the '{@link #getSubMap() <em>Sub Map</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSubMap()
	 * @generated
	 * @ordered
	 */
	protected EList<SubMap> subMap;

	/**
	 * The default value of the '{@link #getColumn() <em>Column</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getColumn()
	 * @generated
	 * @ordered
	 */
	protected static final String COLUMN_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getColumn() <em>Column</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getColumn()
	 * @generated
	 * @ordered
	 */
	protected String column = COLUMN_EDEFAULT;

	/**
	 * The default value of the '{@link #getColumnIndex() <em>Column Index</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getColumnIndex()
	 * @generated
	 * @ordered
	 */
	protected static final Integer COLUMN_INDEX_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getColumnIndex() <em>Column Index</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getColumnIndex()
	 * @generated
	 * @ordered
	 */
	protected Integer columnIndex = COLUMN_INDEX_EDEFAULT;

	/**
	 * The default value of the '{@link #getJavaType() <em>Java Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJavaType()
	 * @generated
	 * @ordered
	 */
	protected static final String JAVA_TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getJavaType() <em>Java Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJavaType()
	 * @generated
	 * @ordered
	 */
	protected String javaType = JAVA_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getJdbcType() <em>Jdbc Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcType()
	 * @generated
	 * @ordered
	 */
	protected static final String JDBC_TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getJdbcType() <em>Jdbc Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcType()
	 * @generated
	 * @ordered
	 */
	protected String jdbcType = JDBC_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getNullValue() <em>Null Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNullValue()
	 * @generated
	 * @ordered
	 */
	protected static final String NULL_VALUE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getNullValue() <em>Null Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNullValue()
	 * @generated
	 * @ordered
	 */
	protected String nullValue = NULL_VALUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getTypeHandler() <em>Type Handler</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypeHandler()
	 * @generated
	 * @ordered
	 */
	protected static final String TYPE_HANDLER_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getTypeHandler() <em>Type Handler</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypeHandler()
	 * @generated
	 * @ordered
	 */
	protected String typeHandler = TYPE_HANDLER_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DiscriminatorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv2Package.Literals.DISCRIMINATOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SubMap> getSubMap() {
		if (subMap == null) {
			subMap = new EObjectContainmentEList<SubMap>(SubMap.class, this, Mapperv2Package.DISCRIMINATOR__SUB_MAP);
		}
		return subMap;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getColumn() {
		return column;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setColumn(String newColumn) {
		String oldColumn = column;
		column = newColumn;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.DISCRIMINATOR__COLUMN, oldColumn, column));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Integer getColumnIndex() {
		return columnIndex;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setColumnIndex(Integer newColumnIndex) {
		Integer oldColumnIndex = columnIndex;
		columnIndex = newColumnIndex;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.DISCRIMINATOR__COLUMN_INDEX, oldColumnIndex, columnIndex));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getJavaType() {
		return javaType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setJavaType(String newJavaType) {
		String oldJavaType = javaType;
		javaType = newJavaType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.DISCRIMINATOR__JAVA_TYPE, oldJavaType, javaType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getJdbcType() {
		return jdbcType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setJdbcType(String newJdbcType) {
		String oldJdbcType = jdbcType;
		jdbcType = newJdbcType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.DISCRIMINATOR__JDBC_TYPE, oldJdbcType, jdbcType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getNullValue() {
		return nullValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNullValue(String newNullValue) {
		String oldNullValue = nullValue;
		nullValue = newNullValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.DISCRIMINATOR__NULL_VALUE, oldNullValue, nullValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getTypeHandler() {
		return typeHandler;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTypeHandler(String newTypeHandler) {
		String oldTypeHandler = typeHandler;
		typeHandler = newTypeHandler;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.DISCRIMINATOR__TYPE_HANDLER, oldTypeHandler, typeHandler));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Mapperv2Package.DISCRIMINATOR__SUB_MAP:
				return ((InternalEList<?>)getSubMap()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv2Package.DISCRIMINATOR__SUB_MAP:
				return getSubMap();
			case Mapperv2Package.DISCRIMINATOR__COLUMN:
				return getColumn();
			case Mapperv2Package.DISCRIMINATOR__COLUMN_INDEX:
				return getColumnIndex();
			case Mapperv2Package.DISCRIMINATOR__JAVA_TYPE:
				return getJavaType();
			case Mapperv2Package.DISCRIMINATOR__JDBC_TYPE:
				return getJdbcType();
			case Mapperv2Package.DISCRIMINATOR__NULL_VALUE:
				return getNullValue();
			case Mapperv2Package.DISCRIMINATOR__TYPE_HANDLER:
				return getTypeHandler();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv2Package.DISCRIMINATOR__SUB_MAP:
				getSubMap().clear();
				getSubMap().addAll((Collection<? extends SubMap>)newValue);
				return;
			case Mapperv2Package.DISCRIMINATOR__COLUMN:
				setColumn((String)newValue);
				return;
			case Mapperv2Package.DISCRIMINATOR__COLUMN_INDEX:
				setColumnIndex((Integer)newValue);
				return;
			case Mapperv2Package.DISCRIMINATOR__JAVA_TYPE:
				setJavaType((String)newValue);
				return;
			case Mapperv2Package.DISCRIMINATOR__JDBC_TYPE:
				setJdbcType((String)newValue);
				return;
			case Mapperv2Package.DISCRIMINATOR__NULL_VALUE:
				setNullValue((String)newValue);
				return;
			case Mapperv2Package.DISCRIMINATOR__TYPE_HANDLER:
				setTypeHandler((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv2Package.DISCRIMINATOR__SUB_MAP:
				getSubMap().clear();
				return;
			case Mapperv2Package.DISCRIMINATOR__COLUMN:
				setColumn(COLUMN_EDEFAULT);
				return;
			case Mapperv2Package.DISCRIMINATOR__COLUMN_INDEX:
				setColumnIndex(COLUMN_INDEX_EDEFAULT);
				return;
			case Mapperv2Package.DISCRIMINATOR__JAVA_TYPE:
				setJavaType(JAVA_TYPE_EDEFAULT);
				return;
			case Mapperv2Package.DISCRIMINATOR__JDBC_TYPE:
				setJdbcType(JDBC_TYPE_EDEFAULT);
				return;
			case Mapperv2Package.DISCRIMINATOR__NULL_VALUE:
				setNullValue(NULL_VALUE_EDEFAULT);
				return;
			case Mapperv2Package.DISCRIMINATOR__TYPE_HANDLER:
				setTypeHandler(TYPE_HANDLER_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv2Package.DISCRIMINATOR__SUB_MAP:
				return subMap != null && !subMap.isEmpty();
			case Mapperv2Package.DISCRIMINATOR__COLUMN:
				return COLUMN_EDEFAULT == null ? column != null : !COLUMN_EDEFAULT.equals(column);
			case Mapperv2Package.DISCRIMINATOR__COLUMN_INDEX:
				return COLUMN_INDEX_EDEFAULT == null ? columnIndex != null : !COLUMN_INDEX_EDEFAULT.equals(columnIndex);
			case Mapperv2Package.DISCRIMINATOR__JAVA_TYPE:
				return JAVA_TYPE_EDEFAULT == null ? javaType != null : !JAVA_TYPE_EDEFAULT.equals(javaType);
			case Mapperv2Package.DISCRIMINATOR__JDBC_TYPE:
				return JDBC_TYPE_EDEFAULT == null ? jdbcType != null : !JDBC_TYPE_EDEFAULT.equals(jdbcType);
			case Mapperv2Package.DISCRIMINATOR__NULL_VALUE:
				return NULL_VALUE_EDEFAULT == null ? nullValue != null : !NULL_VALUE_EDEFAULT.equals(nullValue);
			case Mapperv2Package.DISCRIMINATOR__TYPE_HANDLER:
				return TYPE_HANDLER_EDEFAULT == null ? typeHandler != null : !TYPE_HANDLER_EDEFAULT.equals(typeHandler);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (column: ");
		result.append(column);
		result.append(", columnIndex: ");
		result.append(columnIndex);
		result.append(", javaType: ");
		result.append(javaType);
		result.append(", jdbcType: ");
		result.append(jdbcType);
		result.append(", nullValue: ");
		result.append(nullValue);
		result.append(", typeHandler: ");
		result.append(typeHandler);
		result.append(')');
		return result.toString();
	}

} //DiscriminatorImpl
